<template>
  <div class="header">
    <el-header>
      <div class="title">后台管理系统</div>
      <div>
        {{ name }}<el-button type="primary" @click="signOut">退出</el-button>
      </div>
    </el-header>
  </div>
</template>

<script>
import { getToken, removeToken } from "../../utils/token";
export default {
  data() {
    return {
      name: "",
    };
  },
  created() {
    this.name = getToken("username");
  },
  methods: {
    signOut() {
      removeToken("username");
      removeToken("token");
      this.$router.push("/login");
    },
  },
};
</script>

<style lang="less" scoped>
.header {
  .el-header {
    background-color: #2578b5;
    color: #fff;
    line-height: 60px;
    display: flex;
    justify-content: space-between;
    .title {
      width: 200px;
      font-size: 24px;
    }
    .el-button {
      margin-left: 10px;
    }
  }
}
</style>